package com.lagou.task1.work1;

public class StrWork {

    public static void main(String[] args) {
        String str = "ABCD123!@#$%ab";
        String reg1 = "[A-Z]";
        String reg2 = "[a-z]";
        String reg3 = "[0-9]";
        String reg4 = "[^a-z&A-Z&0-9]";
        int num1 = 0;
        int num2 = 0;
        int num3 = 0;
        int num4 = 0;
        for (int i=0;i<str.length();i++){
            String charAt = str.charAt(i) + "";
            if (charAt.matches(reg1)){
                num1++;
            }else if (charAt.matches(reg2)){
                num2++;
            }else if (charAt.matches(reg3)){
                num3++;
            }else {
//                else if (charAt.matches(reg4)){
//                    System.out.println(str.charAt(i));
//                    num4++;
//                }
                num4++;
            }
        }
        System.out.println("大写字母的个数为" + num1);
        System.out.println("小写字母的个数为" + num2);
        System.out.println("数字的个数为" + num3);
        System.out.println("其他字符的个数为" + num4);
    }
}
